package org.cafeanimal.sqlite;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.cafeanimal.sqlite.util.Strings;

/**
 *
 * @author michael
 */
public class UniqueConstraint extends Constraint {

    UniqueConstraint(Set<Field> sf) {
        super(sf);
    }

    @Override
    public String getSQL() {
        StringBuilder sb = new StringBuilder("UNIQUE(");
        
        List<String> names = new ArrayList<String>();
        for (Field f : fields) {
            names.add(f.getName());
        }
        
        sb.append(Strings.concat(names, ", ")).append(")");
        return sb.toString();
    }
    
}
